/*
 * @Description: 流程 - 接口
 * @Author: DHL
 * @Date: 2022-08-19 15:43:19
 * @LastEditors: DHL
 * @LastEditTime: 2023-11-16 17:22:38
 */

import { $get, $post } from '@/utils/http'
import { FlowProcessStartParams, FlowProcessStartResultModel } from './model/flowProcessStartModel'
import { ContentTypeEnum } from '@/constant/http'
import { Params, Result } from '@/model/baseModel'
import { FlowProcessStopParams, FlowProcessStopResultModel } from './model/flowProcessStopModel'

/**
 * 获取流程实例
 * @param params
 * @returns
 */
export const apiFlowGetProcessInstance = (params: Params) =>
  $get<Result<any>>({
    url: '/flowProcess/getProcessInstance',
    params: params
  })

/**
 * 预览审批路径
 * 根据流程启动参数查询用户任务
 * @param searchParams
 * @returns
 */
export const apiFlowProcessPreview = (searchParams: FlowProcessStartParams) =>
  $post<FlowProcessStartResultModel>({
    url: '/flowProcess/preview',
    contentType: ContentTypeEnum.json,
    params: searchParams
  })

/**
 * 根据流程实例ID预览流程图
 * @param procInsId
 * @returns
 */
export const apiFlowProcessViewer = (params) =>
  $get<Result<any>>({
    url: '/flowProcess/viewer',
    params: params
  })

/**
 * 流程停止
 * @param searchParams
 * @returns
 */
export const apiFlowProcessStop = (stopParams: FlowProcessStopParams) =>
  $post<FlowProcessStopResultModel>({
    url: '/flowProcess/stop',
    contentType: ContentTypeEnum.json,
    params: stopParams
  })

/**
 * 流程实例删除
 * @param deleteParams
 * @returns
 */
export const apiFlowProcessDelete = (deleteParams: FlowProcessStopParams) =>
  $post<Result<string>>({
    url: '/flowProcess/deleteProcinst',
    params: deleteParams
  })
